<?php
/* ******************************
 *	Measure aJax actions
 * ******************************
 */

include('../../includes/classes/core.php');
$action 	= $_REQUEST['act'];
$user_id	= $_SESSION['USERID'];
$error 		= '';
$data 		= '';

switch ($action) {
 	case 'get_list' :
		$count = 		$_REQUEST['count'];
	    $hidden = 		$_REQUEST['hidden'];
	    
	    $rResult = mysql_query("SELECT `id`,
                                       `name`                                          
								FROM   `production_unit`");

		$data = array(
			"aaData"	=> array()
		);
		
		while ( $aRow = mysql_fetch_array( $rResult ) )
		{
			$row = array();
			for ( $i = 0 ; $i < $count ; $i++ )
			{
				/* General output */
				$row[] = $aRow[$i];
			}
			$data['aaData'][] = $row;
		}

        break;
    default:
       $error = 'Action is Null';
}

$data['error'] = $error;

echo json_encode($data);


/* ******************************
 *	Measure Functions
 * ******************************
 */
	


function GetPage($res)
{
	$data = '
	<div id="dialog-form">
	    <fieldset>
	    	<legend>ძირითადი ინფორმაცია</legend>
	    	
	    	<table class="dialog-form-table">
				<tr>
					<td style="width: 170px;"><label for="measure">ზომის ერთეული</label></td>
					<td>
						<input type="text" id="measure" class="idle" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $res['name'] . '" />
					</td>
				</tr>
			</table>
			<!-- ID -->
			<input type="hidden" id="meas_id" value="' . $res['id'] . '" />
        </fieldset>
    </div>
    ';
	return $data;
}

?>